//index.js
//获取应用实例
var e = getApp(), t = e.requirejs("core"), a = e.requirejs("wxParse/wxParse"), i = e.requirejs("biz/diypage");

Page({ 
  data: {
    motto: 'Hello World',
    userInfo: {},
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    // 列表假数据
    fenlist: 
    [
      { 'img': '/images/dingdan.png', 'name': '分销订单', 'bind1': 'toorder', 'bind2': '######' },
      { 'img': '/images/team.png', 'name': '代理商管理', 'bind1': 'tomyteam', 'bind2': '######' },
      { 'img': '/images/ewm.png', 'name': '通知', 'bind1': 'totz', 'bind2': '######' },
      { 'img': '/images/ewm.png', 'name': '客服', 'bind1': 'callme', 'bind2': '######' },
      { 'img': '/images/ewm.png', 'name': '推广二维码', 'bind1': 'qrCode', 'bind2': '######' },
    ]
  },
 
  onShow: function () {
    var e = this;
    t.get("member", {}, function (t) {
      if (0 != t.error){
        wx.redirectTo({
          url: "/pages/message/auth/index"
        })
      }else{
        if (t.isaagent != 1 || t.aagentstatus!=1){
          wx.redirectTo({
            url: '/pages/experts/experts',
          })
        }else{
          e.setData({userInfo:t})
        }
      }      
    });
  },
  qrCode:function(){
    var id = this.data.userInfo.id;
    wx.navigateTo({
      url: '../ewm/ewm?user_id='+id,
    })
  },
  // 联系客服
  callme: function () {
    var that = this;
    wx.makePhoneCall({
      phoneNumber: that.data.userInfo.abonus_phone,
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })
  },
  // 跳转 通知 页面
  totz: function () {
    wx.navigateTo({
      url: '/pages/daili/tz',
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })
  },
  // 跳转 提现明细 页面
  totixian: function () {
    wx.navigateTo({
      url: '/pages/daili/txmx/txmx',
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })
  },
  // 跳转 二维码 页面
  toewm: function () {
    wx.navigateTo({
      url: '../ewm/ewm',
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })
  },
  // 跳转 提现明细 页面
  yongjin: function () {
    wx.navigateTo({
      url: '/pages/daili/yjtx/yjtx',
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })
  },
  // 跳转 分销订单 页面
  toorder: function () {
    wx.navigateTo({
      url: '/pages/daili/fxdd/fxdd',
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })
  },
  // 跳转 我的团队 页面
  tomyteam: function () {
    wx.navigateTo({
      url: '/pages/daili/myteam',
      success: function (res) { },
      fail: function (res) { },
      complete: function (res) { },
    })
  },
  //事件处理函数
  bindViewTap: function () {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
})
